package com.da.javatest.leetCode;

import java.util.Arrays;
import java.util.List;

/**
 * @author chenlida
 * @date 2019/1/12 11:27
 * @description
 */
public class Code788 {
    public static void main(String[] args) {
        new Code788().rotatedDigits(10);
    }

    public int rotatedDigits(int N) {
        List<Integer> l1 = Arrays.asList(2, 5, 6, 9);
        List<Integer> l2 = Arrays.asList(2, 5, 6, 9, 0, 1, 8);
        int count = 0;
        for (int i = 1; i <= N; i++) {
            boolean flag1 = false;
            boolean flag2 = true;
            int num = i;
            while (num != 0) {
                int r = num % 10;
                if (l1.contains(r)) {
                    flag1 = true;
                }
                if (!l2.contains(r)) {
                    flag2 = false;
                    break;
                }
                num /= 10;
            }
            if (flag1 && flag2) {
                count++;
            }
        }
        return count;
    }
}
